<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center harvestAddress_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub harvestAddress_fd0_0'>
          <view class='flex flex-wrap align-center harvestAddress_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  harvestAddress_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='harvestAddress_fd0_0_c1_c0'>我的地址</text>
          </view>
          <view class='flex flex-wrap align-center justify-end harvestAddress_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout">
        <template v-for='(item,key0) in addressList'>
          <view class='flex flex-direction flex-wrap align-stretch harvestAddress_fd1_0' :key='key0' @click="chooseDetail(item)">
            <view class='flex flex-wrap align-center harvestAddress_fd1_0_c0'>
              <text class='harvestAddress_fd1_0_c0_c0'>{{item.user_user_nickname}}</text>
              <text class='harvestAddress_fd1_0_c0_c1'>{{item.mobile}}</text>
            </view>
            <text class='harvestAddress_fd1_0_c1'>{{item.address_detail}}</text>
            <view class='flex flex-wrap align-center'>
              <button class='harvestAddress_fd1_0_c2_c0' @tap.stop="deleteAddressFunc(item.address_id)">删除</button>
              <button class='harvestAddress_fd1_0_c2_c1' @tap.stop="handleJumpDiy" data-type="navigateTo"
                :data-url="`/pages/my/editAddress/editAddress?id=${item.address_id}`">编辑</button>
            </view>
          </view>
        </template>

      </view>

      <!---flex布局flex布局结束-->
      <benben-popup v-model="popupShow1697535571682" :mask="true" :mask-close-able="true" mode='center' :z-index='999'>
        <!---删除地址flex布局开始-->
        <view class="flex flex-direction align-center benben-flex-layout harvestAddress_flex_2">
          <text class='harvestAddress_fd2_0'>确认删除该地址吗？</text>
          <view class='flex flex-wrap align-center'>
            <button class='harvestAddress_fd2_1_c0' @tap.stop="popupShow1697535571682=false">取消</button>
            <button class='harvestAddress_fd2_1_c1' @tap.stop="confirmDeletionFunc()">确认</button>
          </view>
        </view>

        <!---删除地址flex布局结束-->

      </benben-popup>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-center benben-flex-layout" v-if=" addressList.length<=0">
        <image class='harvestAddress_fd3_0' mode="aspectFit" :src='STATIC_URL+"42.png"'></image>
        <text class='harvestAddress_fd3_1'>你还没有收货地址哦，添加一个吧</text>
      </view>

      <!---flex布局flex布局结束-->
      <view class="flex flex-wrap align-stretch justify-center benben-position-layout flex harvestAddress_flex_4">
        <button class='harvestAddress_fd4_0' @tap.stop="handleJumpDiy" data-type="navigateTo"
          :data-url="`/pages/my/editAddress/editAddress`">新增收货地址</button>

      </view>
      <view :style="{height: '120rpx'}"></view>


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "popupShow1697535571682": false,
        "addressList": [],
        "id": "",
        type:''
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      if(options.type){
        this.type=options.type
      }

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {
      this.getaddressListFunc()
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {
      this.getaddressListFunc()
    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      chooseDetail(item){
        if(this.type==1){
          uni.$emit('address',item)
          uni.navigateBack()
        }
      },
      //获取地址列表
      async getaddressListFunc() {
        //请求方法
        //数据验证

        let dataaddressList = await this.$api.get(global.apiUrls.post62c677e63449e, {
          list_rows: '15'
        });

        if (dataaddressList.data.code != 1) {
          this.$message.info(dataaddressList.data.msg);
          return
        }
        let infoaddressList = dataaddressList.data;
        this.addressList = infoaddressList.data
      },
      //删除地址
      deleteAddressFunc(aid) {
        this.id = aid;
        this.popupShow1697535571682 = true;
      },
      //确定删除
      async confirmDeletionFunc() {
        //请求方法
        //数据验证

        let data62d28c0eccdbf = await this.$api.post(global.apiUrls.post62d28c0eccdbf, {
          address_ids: this.id
        });

        if (data62d28c0eccdbf.data.code != 1) {
          this.$message.info(data62d28c0eccdbf.data.msg);
          return
        }


        this.popupShow1697535571682 = false;
        this.getaddressListFunc()
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: var(--benbenbgColor0);
    background-size: 100% auto;
  }

  .harvestAddress_flex_0 {
    background: var(--benbenbgColor1);
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .harvestAddress_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333;
    line-height: 88rpx;
  }

  .harvestAddress_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .harvestAddress_fd0_0_c0 {
    width: 120rpx;
  }

  .harvestAddress_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .harvestAddress_fd1_0_c2_c1 {
    border: 2px solid #E63838;
    background: #E63838;
    border-radius: 32rpx 32rpx 32rpx 32rpx;
    width: 160rpx;
    line-height: 64rpx;
    font-size: 32rpx;
    color: var(--benbenFontColor3);
    height: 64rpx;
  }

  .harvestAddress_fd1_0_c2_c0 {
    border: 2px solid #E63838;
    background: #FFFFFF;
    border-radius: 32rpx 32rpx 32rpx 32rpx;
    width: 160rpx;
    line-height: 64rpx;
    font-size: 32rpx;
    color: rgba(230, 56, 56, 1);
    height: 64rpx;
    margin: 0rpx 24rpx 0rpx auto;
  }

  .harvestAddress_fd1_0_c1 {
    border-bottom: 1px solid #eee;
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
    padding: 0rpx 0rpx 32rpx 0rpx;
    margin: 0rpx 0rpx 32rpx 0rpx;
  }

  .harvestAddress_fd1_0_c0_c1 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 500;
    margin: 0rpx 0rpx 0rpx 24rpx;
  }

  .harvestAddress_fd1_0_c0_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 500;
  }

  .harvestAddress_fd1_0_c0 {
    margin: 0rpx 0rpx 24rpx 0rpx;
  }

  .harvestAddress_fd1_0 {
    background: #FFFFFF;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    margin: 24rpx 24rpx 0rpx 24rpx;
    padding: 32rpx 24rpx 32rpx 24rpx;
  }

  .harvestAddress_flex_2 {
    background: rgba(255, 255, 255, 1);
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    padding: 64rpx 74rpx 48rpx 74rpx;
  }

  .harvestAddress_fd2_1_c1 {
    background: #E63838;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    font-size: 28rpx;
    color: var(--benbenFontColor3);
    margin: 0rpx 0rpx 0rpx 12rpx;
    width: 176rpx;
    height: 72rpx;
  }

  .harvestAddress_fd2_1_c0 {
    background: #F8F8F8;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    font-size: 28rpx;
    color: var(--benbenFontColor0);
    margin: 0rpx 12rpx 0rpx 0rpx;
    width: 176rpx;
    height: 72rpx;
  }

  .harvestAddress_fd2_0 {
    font-size: 32rpx;
    font-weight: 500;
    color: #333333;
    margin: 0rpx 0rpx 56rpx 0rpx;
  }

  .harvestAddress_fd3_1 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
  }

  .harvestAddress_fd3_0 {
    width: 304rpx;
    height: 170rpx;
    margin: 306rpx 0rpx 32rpx 0rpx;
  }

  .harvestAddress_flex_4 {
    background: var(--benbenbgColor0);
    width: 750rpx;
    height: 120rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(0rpx + var(--window-bottom));
    background-size: 100% auto;
  }

  .harvestAddress_fd4_0 {
    background: #E63838;
    border-radius: 44rpx 44rpx 44rpx 44rpx;
    width: 702rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
    height: 88rpx;
  }
</style>
